class BaseError(Exception):

    def __init__(self, errmsg, errcode=0, code=200):
        self.errmsg = errmsg
        self.errcode = errcode
        self.code = code

    def __str__(self):
        msg = 'Error code: {code}, message: {msg}'.format(
            code=self.errcode,
            msg=self.errmsg
        )
        return msg

    def __repr__(self):
        msg = '{klass}({code}, {msg})'.format(
            klass=self.__class__.__name__,
            code=self.errcode,
            msg=self.errmsg
        )
        return msg


class AuthNotAllowError(BaseError):

    def __init__(self, errmsg='无权限通过验证', errcode=401, code=401):
        super(AuthNotAllowError, self).__init__(errmsg, errcode, code)
